﻿using Terraria;
using Terraria.GameContent.ItemDropRules;
using Terraria.ID;
using Terraria.ModLoader;
using Terraria.ModLoader.Utilities;

namespace EAMF.Content.NPCs.Monster
{
    public class BlueCrystal : ModNPC
    {
        public override void SetStaticDefaults()
        {
            Main.npcFrameCount[NPC.type] = 1; //设置npc的帧数
        }
        public override void SetDefaults()
        {
            NPC.width = 22;
            NPC.height = 34;
            NPC.damage = 50;
            NPC.lifeMax = 99999999;
            NPC.defense = 10;
            NPC.knockBackResist = 0f; //被击退能力
            NPC.HitSound = SoundID.NPCHit6;
            NPC.DeathSound = SoundID.NPCDeath7;
            //NPC.buffImmune[BuffID.Poisoned] = true;//免疫中毒
            NPC.value = Item.buyPrice(0, 1, 0, 0);
            NPC.aiStyle =
            AIType = -3;
            AnimationType = -3;
            NPC.noGravity = false; //是否不受重力影响
            NPC.noTileCollide = false;//是否可以穿墙
            //NPC.boss = true; //设置成boss
        }
        //设置自然生成的概率
        public override float SpawnChance(NPCSpawnInfo spawnInfo)
        {
            if (Main.bloodMoon) //如果世界是血月,则生成的概率是1%
            {
                return 1.0f;
            }
            else if (Main.raining) //如果在下雨
            {
                return SpawnCondition.OverworldDaySlime.Chance * 0.5f;//SpwanCondition内置许多的原版怪物的生成方式和概率,这里表示史莱姆生成概率的一半
            }
            return 0.25f; //也可以返回0表示不生成
            //更多的生成条件https://fs49.org/2022/01/18/%e4%bb%8e%e9%9b%b6%e5%bc%80%e5%a7%8b%e7%9a%84npc%e7%bc%96%e5%86%99/
        }
        //重写掉落物
        public override void ModifyNPCLoot(NPCLoot npcLoot)
        {
            ////2%掉落,这里根据世界的帧进行计算
            //if (Main.rand.NextBool(50))
            //{
            //    //LeadingConditionRule notExpertRule = new LeadingConditionRule(new Conditions.NotExpert()); //掉落规则
            //    //notExpertRule.OnSuccess(ItemDropRule.Common(ItemID.StoneBlock, 3, 5, 15));
            //    //npcLoot.Add(notExpertRule); //放入掉落规则
            //    npcLoot.Add(ItemDropRule.Common(ItemID.Sapphire, 5, 10));
            //    //npcLoot.Add(ItemDropRule.BossBag(ItemID.StoneBlock));//可以自定义宝藏袋
            //}
            npcLoot.Add(ItemDropRule.Common(ItemID.Sapphire, 1, 5, 10));
        }
    }
}
